RAIS  3.2
C:/Projekte/RAIS/common/DynamicMaskData.cs
Go to the documentation of this file.
00001 using System;
00002 using System.Collections.Generic;
00003 using System.Data;
00004 using System.Data.SqlClient;
00005 using System.Text;
00006 
00007 using RAIS.Common.TableManagement;
00008 using RAIS.Common.UserManagement;
00009 
00010 namespace RAIS.Common.DynamicMaskManagement
00011 {
00012         public class DynamicMaskData
00013         {
00014                 //*********************************************************************
00015                 #region Fields
00016                 int parentID;
00017                 int tabID;
00018                 UserData currentUser;
00019         int selectedFacilityID;
00020         string selectedFacilityName;
00021         int selectedDepartmentID;
00022         string selectedDepartmentName;
00023         bool isNewRow;
00024                 Dictionary<int, DynamicMask> dynamicMasks;
00025                 Dictionary<int, string> singleListFieldValues;
00026                 List<FieldData> currentRowValues;
00027                 Dictionary<int, DynamicMaskFilterData> filters;
00028                 SqlDataAdapter dataAdapter;
00029                 DataSet dataSet = new DataSet();
00030                 SqlDataAdapter validationDataAdapter;
00031                 DataSet validationDataSet = new DataSet();
00032                 int validationMessageID;
00033                 int sortColumnNumber = 2;
00034                 string sortDirection = Constants.SORT_ORDER_ASCENDING;
00035                 Protector protector = null;
00036                 DynamicMaskData parentDynamicMaskData;
00037                 bool multilookupInsertionNeeded = false;
00038                 bool multilookupDeletionNeeded = false;
00039                 bool validationMultilookupInsertionNeeded = false;
00040                 bool validationMultilookupDeletionNeeded = false;
00041                 #endregion
00042                 //*********************************************************************
00043                 #region Properties
00044 
00045 
00046 
00047                 public int ParentID
00048                 {
00049                         get { return this.parentID; }
00050                         set { this.parentID = value; }
00051                 }
00055         public int TabID
00056                 {
00057                         get { return this.tabID; }
00058                         set { this.tabID = value; }
00059                 }
00063         public UserData CurrentUser
00064                 {
00065                         get { return this.currentUser; }
00066                         set { this.currentUser = value; }
00067                 }
00071         public int SelectedFacilityID
00072         {
00073             get { return this.selectedFacilityID; }
00074             set { this.selectedFacilityID = value; }
00075         }
00079         public string SelectedFacilityName
00080         {
00081             get { return this.selectedFacilityName; }
00082             set { this.selectedFacilityName = value; }
00083         }
00087         public int SelectedDepartmentID
00088         {
00089             get { return this.selectedDepartmentID; }
00090             set { this.selectedDepartmentID = value; }
00091         }
00095         public string SelectedDepartmentName
00096         {
00097             get { return this.selectedDepartmentName; }
00098             set { this.selectedDepartmentName = value; }
00099         }
00103         public bool IsNewRow
00104                 {
00105                         get { return this.isNewRow; }
00106                         set { this.isNewRow = value; }
00107                 }
00111         public Dictionary<int, DynamicMask> DynamicMasks
00112                 {
00113                         get { return this.dynamicMasks; }
00114                         set { this.dynamicMasks = value; }
00115                 }
00119         public DynamicMask DynamicMask
00120                 {
00121                         get 
00122                         {
00123                                 if (this.dynamicMasks.ContainsKey(this.tabID))
00124                                         return this.dynamicMasks[this.tabID];
00125                                 else
00126                                         return null;
00127                         }
00128                 }
00132         public Dictionary<int, string> SingleListFieldValues
00133                 {
00134                         get { return this.singleListFieldValues; }
00135                         set { this.singleListFieldValues = value; }
00136                 }
00140         public List<FieldData> CurrentRowValues
00141                 {
00142                         get { return this.currentRowValues; }
00143                         set { this.currentRowValues = value; }
00144                 }
00148         public Dictionary<int, DynamicMaskFilterData> FiltersData
00149                 {
00150                         get { return this.filters; }
00151                         set { this.filters = value; }
00152                 }
00156         public SqlDataAdapter DataAdapter
00157                 {
00158                         get { return this.dataAdapter; }
00159                         set { this.dataAdapter = value; }
00160                 }
00164                 public DataSet DataSet
00165                 {
00166                         get { return this.dataSet; }
00167                         set { this.dataSet = value; }
00168                 }
00172         public SqlDataAdapter ValidationDataAdapter
00173                 {
00174                         get { return this.validationDataAdapter; }
00175                         set { this.validationDataAdapter = value; }
00176                 }
00180                 public DataSet ValidationDataSet
00181                 {
00182                         get { return this.validationDataSet; }
00183                         set { this.validationDataSet = value; }
00184                 }
00188                 public int ValidationMessageID
00189                 {
00190                         get { return this.validationMessageID; }
00191                         set { this.validationMessageID = value; }
00192                 }
00196         public bool IsMultipaged
00197                 {
00198                         get 
00199                         { 
00200                                 return ((this.dynamicMasks.Count > 1 
00201                                         && this.dynamicMasks[0].Type == DynamicMask.DynamicMaskType.ListWithFilter) 
00202                                                 ? true 
00203                                                 : false); 
00204                         }
00205                 }
00209         public bool IsNextMaskHistory
00210                 {
00211                         get 
00212                         { return (this.DynamicMask.Table.Type == Table.TableType.WithHistory
00213                                                 //&& !this.NeedsValidation
00214                                                 && !(this.DynamicMask.Table.Name == Constants.FACILITY_TABLE_NAME)
00215                                                 && !(this.DynamicMask.Table.Name == Constants.DEPARTMENT_TABLE_NAME)); 
00216                         }
00217                 }
00221         public bool IsHistoryMask
00222                 {
00223                         get 
00224                         {
00225                                 bool isHistory = false;
00226                                 if (this.TabID > 0)
00227                                         isHistory = ((this.DynamicMasks[this.TabID - 1].Type == DynamicMask.DynamicMaskType.SingleRowMask)
00228                                                 && (this.DynamicMasks[this.TabID - 1].Table.Type == Table.TableType.WithHistory));
00229 
00230                                 return isHistory;
00231                         }
00232                 }
00236         public bool NeedsValidation
00237                 {
00238                         get 
00239                         { 
00240                                 return (this.currentUser.FunctionalRole.Validation == FunctionRole.ValidationType.NeedsValidation
00241                                         && this.DynamicMask.Table.NeedsValidation);
00242                         }
00243                 }
00247         public DataRow CurrentRow
00248                 {
00249                         get 
00250                         {
00251                                 if (this.dataSet != null
00252                                         && this.dataSet.Tables.Count != 0
00253                                         && this.dataSet.Tables[0].Rows.Count != 0)
00254                                 {
00255                                         return this.dataSet.Tables[0].Rows[0];
00256                                 }
00257                                 else
00258                                 {
00259                                         return null;
00260                                 }
00261                         }
00262                 }
00266                 public DataRow ValidationCurrentRow
00267                 {
00268                         get
00269                         {
00270                                 if (this.validationDataSet != null
00271                                         && this.validationDataSet.Tables.Count != 0
00272                                         && this.validationDataSet.Tables[0].Rows.Count != 0)
00273                                 {
00274                                         return this.validationDataSet.Tables[0].Rows[0];
00275                                 }
00276                                 else
00277                                 {
00278                                         return null;
00279                                 }
00280                         }
00281                 }
00285         public int CurrentRowKeyValue
00286                 {
00287                         get
00288                         {
00289                                 if (this.CurrentRow == null || this.CurrentRow.ItemArray.Length == 0)
00290                                 {
00291                                         return 0;
00292                                 }
00293                                 else
00294                                 {
00295                                         int keyValue = 0;
00296                                         int.TryParse(this.CurrentRow[0].ToString(), out keyValue);
00297                                         return keyValue;
00298                                 }
00299                         }
00300                 }
00304                 public bool PossibleToAddRow
00305                 {
00306                         get
00307                         {
00308                                 return !(this.IsMultipaged 
00309                                         && this.tabID > 1 
00310                                         && this.DynamicMask.Type == DynamicMask.DynamicMaskType.SingleRowMask
00311                                         && this.CurrentRow != null);
00312                         }
00313                 }
00317                 public bool PossibleToEditRow
00318                 {
00319                         get
00320                         {
00321                                 return (this.CurrentRow != null);
00322                         }
00323                 }
00327         public bool PossibleToDeleteRow
00328                 {
00329                         get
00330                         {
00331                                 return (this.CurrentRow != null);
00332                         }
00333                 }
00337         public bool PossibleToViewLog
00338                 {
00339                         get
00340                         {
00341                                 return (this.CurrentRow != null);
00342                         }
00343                 }
00347         public int SortColumnNumber
00348                 {
00349                         get { return sortColumnNumber; }
00350                         set { sortColumnNumber = value; }
00351                 }
00355         public string SortDirection
00356                 {
00357                         get { return sortDirection; }
00358                         set { sortDirection = value; }
00359                 }
00363         public Protector Protector
00364                 {
00365                         get { return protector; }
00366                         set { protector = value; }
00367                 }
00371         public DynamicMaskData ParentDynamicMaskData
00372                 {
00373                         get { return this.parentDynamicMaskData; }
00374                         set { this.parentDynamicMaskData = value; }
00375                 }
00379                 public bool MultilookupInsertionNeeded
00380                 {
00381                         get { return this.multilookupInsertionNeeded; }
00382                         set { this.multilookupInsertionNeeded = value; }
00383                 }
00387         public bool MultilookupDeletionNeeded
00388                 {
00389                         get { return this.multilookupDeletionNeeded; }
00390                         set { this.multilookupDeletionNeeded = value; }
00391                 }
00395         public bool ValidationMultilookupInsertionNeeded
00396                 {
00397                         get { return this.validationMultilookupInsertionNeeded; }
00398                         set { this.validationMultilookupInsertionNeeded = value; }
00399                 }
00403         public bool ValidationMultilookupDeletionNeeded
00404                 {
00405                         get { return this.validationMultilookupDeletionNeeded; }
00406                         set { this.validationMultilookupDeletionNeeded = value; }
00407                 }
00408                 #endregion
00409                 //*********************************************************************
00410                 #region Constructors
00411                 public DynamicMaskData()
00412                 { }
00413                 #endregion
00414                 //*********************************************************************
00415                 #region Public Methods
00416 
00417 
00418 
00419         public void AddRow()
00420                 {
00421                         this.dataSet.Tables[0].Rows.Add();
00422                 }
00426                 public void AddValidationRow()
00427                 {
00428                         this.validationDataSet.Tables[0].Rows.Add();
00429                 }
00435         public int GetPKValueByRowIndex(int rowIndex)
00436                 {
00437                         int pkValue = 0;
00438 
00439                         if (this.dataSet != null
00440                                 && this.dataSet.Tables.Count != 0
00441                                 && this.dataSet.Tables[0].Rows.Count > rowIndex
00442                                 && this.dataSet.Tables[0].Columns.Count > 0)
00443                         {
00444                                 pkValue = (int)this.dataSet.Tables[0].Rows[rowIndex][0];
00445                         }
00446 
00447                         return pkValue;
00448                 }
00454                 public int GetRowIndexByPKValue(int pkValue)
00455                 {
00456                         int rowIndex = -1;
00457 
00458                         if (this.dataSet != null
00459                                 && this.dataSet.Tables.Count != 0
00460                                 && this.dataSet.Tables[0].Rows.Count > 0
00461                                 && this.dataSet.Tables[0].Columns.Count > 0)
00462                         { 
00463                                 int index = 0;
00464                                 foreach(DataRow dataRow in  this.dataSet.Tables[0].Rows)
00465                                 {
00466                                         if (dataRow[0].ToString() == pkValue.ToString())
00467                                         {
00468                                                 rowIndex = index;
00469                                                 break;
00470                                         }
00471                                         index++;
00472                                 }
00473                         }
00474 
00475                         return rowIndex;
00476                 }
00481         public DataSet GetDataSet()
00482                 {
00483                         return this.dataSet;
00484                 }
00485                 #endregion Public Methods
00486         }
00487 }